package com.ewanghuiju.app.widget.popupwindow;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;

import com.bigkoo.pickerview.view.TimePickerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.ewanghuiju.app.R;
import com.ewanghuiju.app.model.bean.local.WalletClassifyBean;
import com.ewanghuiju.app.ui.my.adapter.WalletClassifyFlexboxAdapter;
import com.ewanghuiju.app.util.LoadingDialogUtils;
import com.ewanghuiju.app.util.TimeUtils;
import com.ewanghuiju.app.widget.CustomPickerView;
import com.google.android.flexbox.FlexDirection;
import com.google.android.flexbox.FlexWrap;
import com.google.android.flexbox.FlexboxLayoutManager;

import java.util.Date;
import java.util.List;

import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import razerdp.basepopup.BasePopupWindow;

/**
 * @author sj  qq:751943509
 * @class 钱包分类的弹框
 * @time 2020/2/19
 */
public class WalletSelectedTimePopup extends BasePopupWindow {
    @BindView(R.id.layout_main)
    LinearLayout layoutMain;

    WalletSelectedTimePopupCallback walletSelectedTimePopupCallback;

    public WalletSelectedTimePopup(Context context, WalletSelectedTimePopupCallback walletSelectedTimePopupCallback) {
        super(context);
        setWidth(getScreenWidth());
        ButterKnife.bind(this, getContentView());
        this.walletSelectedTimePopupCallback = walletSelectedTimePopupCallback;
        setCustomPickerView();
    }

    private TimePickerView pvCustomTime;
    public void setCustomPickerView() {
        if (pvCustomTime != null) {
            pvCustomTime.show();
            return;
        }
        pvCustomTime = new CustomPickerView().getNewTimePick(getContext(), new boolean[]{true, true, true, false, false, false},layoutMain, new CustomPickerView.OnOptionsSureListener() {
            @Override
            public void onOptionsSureSelect(int options1, int options2, int options3, View v) {

            }

            @Override
            public void onTimeSureSelect(Date date, View v) {
//                currentDate = TimeUtils.date2String(date, "yyyy-MM");
//                tvDate.setText(currentDate);
//                LoadingDialogUtils.show(activity);
//                currentPage = 1;
//                mPresenter.getData(currentPage, mType + "", currentDate, currentStatus + "");
                if(walletSelectedTimePopupCallback!=null){
                    walletSelectedTimePopupCallback.onSureClickCallback(TimeUtils.date2String(date, "yyyy-MM-dd"));
                }
            }

            @Override
            public void onSureOrCancel() {
                dismiss();
            }
        });
        pvCustomTime.show(false);
    }


    @Override
    public View onCreateContentView() {
        return createPopupById(R.layout.popup_wallet_selecte_time);
    }

    public interface WalletSelectedTimePopupCallback {
        //确认按钮
        void onSureClickCallback(String currentDate);
    }
}
